<template>
  <div class="playlist">
    <div class="img_box">
      <van-image lazy-load radius="10" :src="recommend.picUrl" />
      <span class="count"
        ><i class="iconfont icon-bofang1"></i> {{ count }}</span
      >
    </div>
    <p class="van-multi-ellipsis--l2 text">
      {{ recommend.name }}
    </p>
  </div>
</template>

<script lang="ts">
import { computed, defineComponent } from 'vue'

export default defineComponent({
  name: 'ImageTextList',
  props: {
    recommend: {
      type: Object,
      default: () => {
        return {}
      },
    },
  },
  setup(props) {
    const count = computed(() => {
      let num = ''
      if (
        props.recommend.playcount >= 100000 &&
        props.recommend.playcount < 100000000
      ) {
        num = props.recommend.playcount.toString().slice(0, -4) + '万'
      } else if (props.recommend.playcount < 100000) {
        num = props.recommend.playcount.toString()
      } else if (props.recommend.playcount >= 100000000) {
        num = props.recommend.playcount.toString().slice(0, -8) + '亿'
      }
      return num
    })

    return {
      count,
    }
  },
})
</script>

<style lang="less" scoped>
.playlist {
  width: 105px;
  margin-right: 10px;
  &:last-of-type {
    margin-right: 0;
  }
  .img_box {
    position: relative;
    width: 105px;
    height: 105px;
    .van-image {
      width: 100%;
      height: 100%;
    }
    .count {
      position: absolute;
      right: 10px;
      top: 6px;
      display: inline-block;
      padding: 2px 10px;
      font-size: 14px;
      color: var(--sky-text-white-color);
      border-radius: 30px;
      background-color: var(--sky-rgba-black3-background-color);
      .icon-bofang1 {
        font-size: 14px;
        color: var(--sky-text-white-color);
      }
    }
  }
  .text {
    font-size: 14px;
    color: var(--sky-text-black-color);
    margin-top: 3px;
  }
}
</style>